﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestTasks
{
    public class SingleDetector
    {
        public IEnumerable<byte> Detect(IEnumerable<byte> stream)
        {
            byte master = 0;
            var buckets = new byte[] {0, 0, 0, 0, 0, 0, 0, 0};

            foreach (var item in stream)
            {
                master ^= item;
                for (var i = 0; i < 8; i++) if ((item &(1 << i)) > 0)
                {
                    buckets[i] ^= item;
                }
            }

            var e = buckets.First(x => x != master);
            yield return e;
            yield return (byte)(e^master);
        }
    }
}
